<template>
    <div class="ec-site">
        <el-row>
            <el-breadcrumb separator=">">
                <el-breadcrumb-item >基础设置</el-breadcrumb-item>
                <el-breadcrumb-item>电商管理</el-breadcrumb-item>
            </el-breadcrumb>
        </el-row>
        <el-row>
            <el-button type="text" @click="$refs['ecSiteDetail'].show()">新增</el-button>
            <el-table
            :data="tableDat" stripe>
                <el-table-column
                    prop="name"
                    label="名称">
                </el-table-column>
                <el-table-column
                    prop="domain"
                    label="域名">
                </el-table-column>
                <el-table-column
                    prop="payment_term"
                    label="账期">
                </el-table-column>
                 <el-table-column
                    prop="no"
                    label="财务对账">
                </el-table-column>
                <el-table-column
                    label="单位">
                    <template slot-scope="scope">
                        {{scope.row.measure_unit | unitFormat}}
                    </template>
                </el-table-column>
                <el-table-column
                    label="操作">
                    <template slot-scope="scope">
                        <el-button type="text" size="large" @click="$refs['ecSiteDetail'].show(scope.row.id)">编辑</el-button>
                    </template>
                </el-table-column>
                <el-table-column label="vue2.6 v-slot 插槽">
                    <template v-slot="scope">
                        <el-button type="text" size="large" >{{ scope.row.id }}</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-row>

        <ec-site-detail ref="ecSiteDetail"
        @success="ecsiteList" />
        
    </div>
</template>

<script>
import sdApi from '../../api/sd';
import EcSiteDetail from './EcSiteDetail.vue';

export default {
    components: {
        EcSiteDetail
    },
    data() {
        return {
            tableDat: [{
                name: 'Amazon 英国',
                domain: 'Amazon.de',
                created_at: '',
                measure_unit: '',
                updated_at: '',
                id: '',
            }],

            
        };
    },
    filters: {
      unitFormat(val) {
        switch (val) {
          case 'metrics':
            return '国际单位';
          case 'imperial':
            return '英制单位';
        }
      }
    },
    created() {
       this.ecsiteList();
    },
    methods: {
        ecsiteList() {
            sdApi.ecSite().then(res=>{
                this.tableDat = res.data.sites;
            });
        },
       
    },



};
</script>
<style>
    .el-row {
    margin-bottom: 20px;
    
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
</style>
